CP = cp 
CD = cd 
DD = dd 
RM = rm 

LKIMG = ./lmoskrlimg -m k
MAKE = make 
X86BARD = -f ./Makefile.x86 


KRNLEXCIMG = Cosmos.bin

LOGOFILE = logo.bmp background.bmp
FONTFILE = font.fnt

BUILD_PATH = ./build
EXKNL_PATH = ./exckrnl
DSTPATH = ../exckrnl
RELEDSTPATH = ../release/
INITLDR_PATH = ./initldr/
CPLILDR_PATH = ./release/
INITLDR_BUILD_PATH = ./initldr/build/
INSTALL_PATH = /boot/
INSTALLSRCFILE_PATH = ./release/Cosmos.eki

VVMRLMOSFLGS = -C $(BUILD_PATH) -f vbox.mkf

SRCFILE = $(BOOTEXCIMG) $(KRNLEXCIMG) $(LDEREXCIMG) $(SHELEXCIMG)
RSRCFILE = $(BOOTEXCIMG) $(KRNLEXCIMG) $(LDEREXCIMG) $(SHELEXCIMG)

INITLDRIMH = initldrimh.bin
INITLDRKRL = initldrkrl.bin 
INITLDRSVE = initldrsve.bin

CPLILDRSRC = $(INITLDR_BUILD_PATH)$(INITLDRIMH) $(INITLDR_BUILD_PATH)$(INITLDRKRL) $(INITLDR_BUILD_PATH)$(INITLDRSVE)

LKIMG_INFILE = $(INITLDRKRL) $(INITLDRSVE) $(KRNLEXCIMG) $(FONTFILE) $(LOGOFILE)
.PHONY : install x32 build print clean all krnlexc cpkrnl wrimg phymod exc vdi vdiexc cprelease release createimg

build: clean print all

all:
	$(MAKE)	$(X86BARD)
	@echo	'恭喜我，系统编译构建完成！ (*^__^*) '
clean:
	$(CD)	$(INITLDR_PATH);	$(MAKE)	clean
	$(CD)	$(BUILD_PATH);	$(RM)	-f *.o *.bin *.i *.krnl *.s *.map *.lib *.btoj *.vdi *.elf *vmdk *.lds *.mk *.mki krnlobjs.mh
	$(CD)	$(EXKNL_PATH);	$(RM)	-f *.o *.bin *.i *.krnl *.s *.map *.lib *.btoj *.vdi *.elf *vmdk *.lds *.mk *.mki krnlobjs.mh
	$(CD)	$(CPLILDR_PATH);	$(RM) -f *.o *.bin *.i *.krnl *.s *.eki *.map *.lib *.btoj *.elf *.vdi *vmdk *.lds *.mk *.mki krnlobjs.mh
	@echo 'Cosmos清理全部已构建文件...^_^'


VBOXRUN:
	$(MAKE)  $(VVMRLMOSFLGS)

release: clean all cplmildr cpkrnl cprelease KIMG

cplmildr:
	$(CP)	$(CPFLAGES) $(CPLILDRSRC) $(CPLILDR_PATH)
cpkrnl:
	$(CD)	$(BUILD_PATH) && $(CP) $(CPFLAGES) $(SRCFILE) $(DSTPATH)
cprelease:
	$(CD)	$(EXKNL_PATH) && $(CP) $(CPFLAGES) $(RSRCFILE) $(RELEDSTPATH)
KIMG:
	@echo '正在生成Cosmos内核映像文件，请稍后……'
	$(CD) $(CPLILDR_PATH) && $(LKIMG) -lhf $(INITLDRIMH) -o Cosmos.eki -f $(LKIMG_INFILE)

vboxtest: release VBOXRUN